<!doctype html>
<html class="no-js fixed-layout">
<head>
<% include("/common/shop_head.html"){}%>
</head>
<body>
<div class="am-cf">
  <!-- content start -->
  <div class="shop-content">
    <div class="shop-content-body">
      <div class="am-panel am-panel-default">
        <div class="am-panel-hd am-text-center">找回密码</div>
        <div class="am-panel-bd">
          <form id="passwordRecoverForm" class="am-form am-form-horizontal" action="${base}/shop/member/sendPasswordRecoverMail" method="post" data-am-validator>
          <div class="am-form-group">
            <label class="am-u-sm-3 am-form-label">用户名</label>
            <div class="am-u-sm-9">
              <input type="text" class="am-form-field first-submit" name="member.username" placeholder="请填写用户名!" required />
            </div>
          </div>
          <div class="am-form-group">
            <label class="am-u-sm-3 am-form-label">E-mail</label>
            <div class="am-u-sm-9">
              <input type="email" class="am-form-field first-submit" name="member.email" placeholder="请填写E-mail!" required />
            </div>
          </div>
          <div class="safe-problem am-hide">
          <div class="am-form-group">
            <label class="am-u-sm-3 am-text-right">问题</label>
            <div class="am-u-sm-9" id="problem-content">
            </div>
          </div>
          <div class="am-form-group">
            <label class="am-u-sm-3 am-form-label">答案</label>
            <div class="am-u-sm-9">
              <input type="text" class="am-form-field" id="safeAnswerInput" name="member.safeAnswer" placeholder="请填写密码保护回答！" />
            </div>
          </div>
          </div>
          <div class="am-form-group">
            <div class="am-u-sm-9 am-u-sm-offset-3">
              <button id="passwordRecoverFormBtn" type="submit" class="am-btn am-btn-default" data-am-loading="{loadingText: '努力校验中...'}">确  定</button>
            </div>
            <div class="am-u-sm-9 am-u-sm-offset-3 am-text-warning am-text-xs">
              如果忘记密码，请填写您的用户名和注册邮箱重新获取密码！
            </div>
          </div>
          </form>
        </div>
      </div>
    </div>
    <%include("/shop/footer.html"){}%>
  </div>
  <!-- content end -->
</div>
<script type="text/javascript">
$().ready(function() {
  //密码找回表单提交
  $('#passwordRecoverForm').on('submit', function() {
    if($(this).validator('isFormValid')){
      $("#passwordRecoverFormBtn").button('loading');
      $(this).ajaxSubmit({
        dataType: "json",
        success: function(data) {
          Modal.alert(data.message);
          if (data.status == "warn") {
            $("#problem-content").html(data.safeQuestion);
            $("#safeAnswerInput").attr('required','required');
            $(".first-submit").attr('readonly','true');
            $(".safe-problem").removeClass("am-hide");
            $("#safeAnswerInput").focus();
          } 
          $("#passwordRecoverFormBtn").button('reset');
        }
      });
    }
    return false; // 阻止表单自动提交事件
  });
    
});
</script>
</body>
</html>